package tools;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class BaseDAO {
	public static final String DB_DRIVER = "com.mysql.jdbc.Driver";
	public static final String DB_URL = "jdbc:mysql:///student";
	public static final String DB_USER = "root";
	public static final String DB_PWD =	"19970928";
	
	public static Connection getConn() throws Exception{
		Class.forName(DB_DRIVER);
		return DriverManager.getConnection(DB_URL,DB_USER,DB_PWD);
	}
	
	public static void closeAll(ResultSet rs,Statement ps,Connection conn){
		if (null!= rs) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		
		if (null!= ps) {
			try {
				ps.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		
		if (null!= conn) {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
}
